package com.wangchao.administrator.zenmechi.ui.detailactivity;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.wangchao.administrator.zenmechi.bean.goodsdetail.GoodsDetail;

import java.util.Map;

import rx.Subscriber;

/**
 * Created by My on 2016/10/19.
 */
public class DetailPresenter implements DetailContract.Presenter {
    private DetailContract.Model model;
    private DetailContract.View view;

    public DetailPresenter(DetailContract.View view) {
        this.model = new DetailModel();
        this.view = view;
    }


    @Override
    public void getNetworkDate( String id, Map<String, String> stringMap) {
        model.getNetworkDate(new Subscriber<GoodsDetail>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {
            }

            @Override
            public void onNext(GoodsDetail goodsDetail) {
                if (goodsDetail!=null)
                view.onSuccess(goodsDetail);
            }
        },id,stringMap);
    }
    @Override
    public void loadingInmage(ImageView imageView, Context context, String urlString){
        Glide.with(context).load(urlString).into(imageView);
    }
}
